package com.wltjack.springboot.config;

import org.springframework.context.annotation.Configuration;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * 
 * Swagger配置
 * 启动Spring boot程序，访问: http://127.0.0.1:8080/learn/swagger-ui.html
 *
 */
@Configuration
@EnableSwagger2 // 启用Swagger2
public class SwaggerConfig {
	
	public Docket createRestApi() {
		return new Docket(DocumentationType.SWAGGER_2)
				.apiInfo(apiInfo())
				.select()
				.apis(RequestHandlerSelectors.basePackage("com.wltjack.springboot.controller"))
				.paths(PathSelectors.any())
				.build();
	}
	
	private ApiInfo apiInfo() {
		return new ApiInfoBuilder()
				.title("springBoot-learn接口文档")
				.description("springBoot-learn接口文档")
				.contact("wltjack")
				.version("1.0").build();
	}

}
